package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.pojo.Img;
import com.example.mapper.ImgMapper;
import com.example.service.IImgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.vo.ResultVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 图片表 服务实现类
 * </p>
 *
 * @author wsl
 * @since 2022-04-23
 */
@Service
public class ImgServiceImpl extends ServiceImpl<ImgMapper, Img> implements IImgService {

    @Override
    public ResultVo getMenuIconOptions(String keyword) {
        QueryWrapper<Img> wrapper = new QueryWrapper<>();
        wrapper.select("id,name,url")
                .like(keyword!=null,"name",keyword)
                .or().like(keyword!=null,"depict",keyword)
                .eq("type_id",1);
        List<Map<String, Object>> menuIcons = baseMapper.selectMaps(wrapper);
        return ResultVo.response(menuIcons);
    }
}
